Analyzing data gathered from fitness wearables or smartwatches is essential for gaining valuable insights into users' health and activity patterns. These devices record various metrics such as step count, calorie expenditure, walking speed, and more.
The process of Fitness Watch Data Analysis holds significant importance for businesses operating in the health and wellness sector. It enables these companies to gain a deeper understanding of user behavior, provide tailored solutions, and play a role in enhancing the overall health and well-being of their users.
Process We Can Follow:
Now let’s get started with the task of Fitness Watch Data Analysis by importing the necessary Python libraries and the dataset:
import pandas as pd
import plotly.io as pio
import plotly.graph_objects as go
pio.templates.default = "plotly_white"
import plotly.express as px
data = pd.read_csv("Apple-Fitness-Data.csv")
print(data.head())
Date Time Step Count Distance Energy Burned \ 0 2023-03-21 16:01:23 46 0.02543 14.620 1 2023-03-21 16:18:37 645 0.40041 14.722 2 2023-03-21 16:31:38 14 0.00996 14.603 3 2023-03-21 16:45:37 13 0.00901 14.811 4 2023-03-21 17:10:30 17 0.00904 15.153 Flights Climbed Walking Double Support Percentage Walking Speed 0 3 0.304 3.060 1 3 0.309 3.852 2 4 0.278 3.996 3 3 0.278 5.040 4 3 0.281 5.184
Let’s have a look if this data contains any null values or not:
print(data.isnull().sum())
Date 0 Time 0 Step Count 0 Distance 0 Energy Burned 0 Flights Climbed 0 Walking Double Support Percentage 0 Walking Speed 0 dtype: int64
So, the data doesn’t have any null values. Let’s move further by analyzing my step count over time:
# Step Count Over Time
lg = px.line(data, x="Time",
y="Step Count",
title="Step Count Over Time")
lg.show()
Now, let’s have a look at the distance covered over time:
# Distance Covered Over Time
lg2 = px.line(data, x="Time",
y="Distance",
title="Distance Covered Over Time")
lg2.show()
Now, let’s have a look at my energy burned over time:
# Energy Burned Over Time
fig3 = px.line(data, x="Time",
y="Energy Burned",
title="Energy Burned Over Time")
fig3.show()
Now, let’s have a look at my walking speed over time:
# Walking Speed Over Time
fig4 = px.line(data, x="Time",
y="Walking Speed",
title="Walking Speed Over Time")
fig4.show()
Now, let’s calculate and look at the average step counts per day:
# Calculate Average Step Count per Day
average_step_count_per_day = data.groupby("Date")["Step Count"].mean().reset_index()
fig5 = px.bar(average_step_count_per_day, x="Date",
y="Step Count",
title="Average Step Count per Day")
fig5.update_xaxes(type='category')
fig5.show()
Now, let’s have a look at my walking efficiency over time:
# Calculate Walking Efficiency
data["Walking Efficiency"] = data["Distance"] / data["Step Count"]
fig6 = px.line(data, x="Time",
y="Walking Efficiency",
title="Walking Efficiency Over Time")
fig6.show()
Now, let’s have a look at the step count and walking speed variations by time intervals:
# Create Time Intervals
time_intervals = pd.cut(pd.to_datetime(data["Time"]).dt.hour,
bins=[0, 12, 18, 24],
labels=["Morning", "Afternoon", "Evening"],
right=False)
data["Time Interval"] = time_intervals
# Variations in Step Count and Walking Speed by Time Interval
fig7 = px.scatter(data, x="Step Count",
y="Walking Speed",
color="Time Interval",
title="Step Count and Walking Speed Variations by Time Interval",
trendline='ols')
fig7.show()
C:\Users\DELL\AppData\Local\Temp\ipykernel_14988\2894008012.py:2: UserWarning: Could not infer format, so each element will be parsed individually, falling back to `dateutil`. To ensure parsing is consistent and as-expected, please specify a format. C:\Users\DELL\AppData\Local\Programs\Python\Python311\Lib\site-packages\plotly\express\_core.py:2044: FutureWarning: The default of observed=False is deprecated and will be changed to True in a future version of pandas. Pass observed=False to retain current behavior or observed=True to adopt the future default and silence this warning.